Release 10.1A: OpenEdge Getting Started:
Object-oriented Programming


Checking and running a class from the Procedure Editor

The RUN functionality from the Procedure Editor (F2 for GUI, F1 for character mode) allows you to instantiate a class file from the current edit buffer, based on the file extension of the edit buffer. If the current edit buffer is an untitled edit buffer (that is, has not been explicitly saved as a .cls file), the Procedure Editor, by default, interprets it as a procedure file, regardless of its content. Thus, if you try to compile an untitled edit buffer that contains a CLASS or INTERFACE statement, the Procedure Editor notifies you that you have class file syntax and need to save the edit buffer to a file before compiling it.

If the code has been explicitly saved as a class file, the Procedure Editor interprets it as a class file, again, regardless of its content. Thus, it will compile only if it contains a CLASS or INTERFACE statement. That is, when running the current edit buffer, the Procedure Editor does not initially parse the source code to check for the presence of the CLASS or INTERFACE statement, but relies entirely on the filename extension with which the file has been saved to determine what syntax it needs to check for (class or procedure syntax).

In addition, depending on whether the current edit buffer has been saved to or loaded from a file or is untitled (never saved to a file), the Procedure Editor handles code a little differently when checking the syntax or running the code.

Check Syntax option

For an edit buffer loaded from or saved to a file, the Compile Check Syntax option of the Procedure Editor determines what syntax it must contain based on the filename extension. A class (.cls) file must contain CLASS or INTERFACE syntax, or the Procedure Editor generates a syntax error when checking the syntax. Any other type of file must not contain CLASS or INTERFACE syntax, or the compiler generates a syntax error when checking the syntax. For an already loaded or saved edit buffer, you do not have to save changes again in order to check syntax.

For an untitled edit buffer, the Procedure Editor determines if the edit buffer contains CLASS or INTERFACE syntax and checks the syntax accordingly. Once you save the untitled edit buffer to a file, the Procedure Editor checks syntax as a loaded or saved edit buffer according to the filename extension.

Run option

For an edit buffer loaded from or saved to a file, the Compile Run option of the Procedure Editor determines what syntax it must contain based on the filename extension. A class (.cls) file must contain CLASS or INTERFACE syntax, or the Procedure Editor generates a syntax error when it tries to run the file. Any other type of file must not contain CLASS or INTERFACE syntax, or the Procedure Editor generates a syntax error when trying to run the file.

Note that for a class file, you must save any changes to a loaded or saved edit buffer in order for the Procedure Editor to execute them. In other words, the Procedure Editor always executes the last saved version of the class file in the current edit buffer.

For an untitled edit buffer, the Procedure Editor does not allow you to run the code if the edit buffer contains CLASS or INTERFACE syntax. You must first save the untitled edit buffer to a file with the .cls extension and to the PROPATH-relative filename specified by the class or interface type name defined in the file. For more information on class or interface type names, see the "Using the CLASS construct" section or the "Using the INTERFACE construct" section, respectively. Again, remember to save your latest changes before trying to run them in a saved edit buffer, as the Procedure Editor always runs the code that is actually on disk.


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095